function [n, Wn] = custom_buttoord(Wp, Ws, Rp, Rs)
    % Wp: 通带截止频率 (归一化频率)
    % Ws: 阻带截止频率 (归一化频率)
    % Rp: 通带纹波 (dB)
    % Rs: 阻带衰减 (dB)

    % 计算滤波器阶数
    Wp=tan(pi*Wp/2);
    Ws=tan(pi*Ws/2);
    WA= Ws/Wp;
    WA=min(abs(WA));
    n = log10( (10 .^ (0.1*abs(Rs)) - 1)./ (10 .^ (0.1*abs(Rp)) - 1) ) / (2*log10(WA));
    n = ceil(n); % 向上取整
    % 计算归一化截止频率
    W0 = WA / ( (10^(.1*abs(Rs)) - 1)^(1/(2*(abs(n)))));
    Wn = (2/pi)*atan(W0*Wp);
end
